<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="昵称">
              <a-input placeholder="请输入昵称" v-model="queryParam.nickName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户类型">
              <a-select v-model="queryParam.userType" placeholder="请选择用户类型">
                <a-select-option value="">全部</a-select-option>
                <a-select-option value="1">宝妈</a-select-option>
                <a-select-option value="2">月嫂</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
		  <a-col :xl="8" :lg="8" :md="8" :sm="24">
		    <a-form-item label="注册日期">
				<a-range-picker
				  :allowClear="false"
				  v-model="weekDateRange"
				  @change="onChange"
				  format="YYYY-MM-DD" />
		    </a-form-item>
		  </a-col>
          <a-col :xl="4" :lg="6" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('用户列表')">导出</a-button> -->
      <!-- <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown> -->
    </div>

    <!-- table区域-begin -->
    <div>
     <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
		 @change="handleTableChange">

        <span slot='avaterUrlSlot' slot-scope="text, record">
<!--          //<img :src='text.avaterUrl' alt='' />-->
          <div class="anty-img-wrap">
            <a-avatar shape="square" :src="text.avaterUrl" icon="user"/>
          </div>
        </span>

        <span slot='sexSlot' slot-scope="text, record">
          <a-tag color="blue" v-if='text.sex==1'>男</a-tag>
          <a-tag color="green" v-if='text.sex==2'>女</a-tag>
        </span>
        <span slot='userTypeSlot' slot-scope="text, record">
          <a-tag color="blue" v-if='text.userType==1'>宝妈</a-tag>
          <a-tag color="green" v-if='text.userType==2'>月嫂</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">详情</a>
          <a-divider type="vertical" /> 
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <wechatUser-modal ref="modalForm" @ok="modalFormOk"></wechatUser-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import WechatUserModal from './modules/WechatUserModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: "WechatUserList",
    mixins:[JeecgListMixin],
    components: {
      WechatUserModal
    },
    data () {
      return {
		weekDateRange: [],
        description: '需求记录管理页面',
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          //  },
		   {
            title: '昵称',
            align:"center",
            dataIndex: 'nickName'
           },
          {
            title: '用户类型',
            align:"center",

            scopedSlots: { customRender: 'userTypeSlot' }
          },
		   {
            title: '头像',
            align:"center",
            //dataIndex: 'avaterUrl'
            scopedSlots: { customRender: 'avaterUrlSlot' }
           },
		   // {
     //        title: '性别',
     //        align:"center",
     //        scopedSlots: { customRender: 'sexSlot'}
     //       },
		   // {
     //        title: '住址',
     //        align:"center",
     //        dataIndex: 'address'
     //       },
          {
            title: '手机号',
            align:"center",
            dataIndex: 'phoneNum'
          },
		   {
            title: '注册时间',
            align:"center",
            dataIndex: 'createTime'
           },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
          list: "/wechat/wechatUser/list",
          delete: "/wechat/wechatUser/delete",
          deleteBatch: "/wechat/wechatUser/deleteBatch",
          exportXlsUrl: "wechat/wechatUser/exportXls",
          importExcelUrl: "wechat/wechatUser/importExcel",
       },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
		onChange(date,dateString){
			this.queryParam.createTime_begin = dateString[0]+' 00:00:00'
			this.queryParam.createTime_end = dateString[1]+' 23:59:59'
		}
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>